package com.yohann.designPattern.proxy.jdk;

import com.yohann.designPattern.proxy.staticproxy.ITeacherDao;
import com.yohann.designPattern.proxy.staticproxy.TeacherDao;

/**
 * <p>
 * jdk代理客户端
 * </p>
 *
 * @author Yohann
 * @since 2021/2/8 16:50
 */
public class Client {
    public static void main(String[] args) {
        ITeacherDao target = new TeacherDao();
        ITeacherDao instance = (ITeacherDao) new ProxyFactory(target).getProxyInstance();

        /*
        jdk proxy start
        jdk proxy end
        com.yohann.designPattern.proxy.staticproxy.TeacherDao@568db2f2
         */
        System.out.println(instance);

        /*
        class com.sun.proxy.$Proxy0
         */
        System.out.println(instance.getClass());

        /*
        jdk proxy start
        teaching
        jdk proxy end
         */
        instance.teach();
    }
}